package com.gitee.qdbp.general.trade.api.personal.model;

import com.gitee.qdbp.base.annotation.DataIsolation;
import com.gitee.qdbp.base.annotation.OperateTraces;
import com.gitee.qdbp.base.enums.DataState;

/**
 * 用户地址实体类
 *
 * @author zhh
 * @version 180716
 */
@OperateTraces(id = "id")
@DataIsolation(enable = false)
public class PersonalAddressBean extends PersonalAddressBase {

    /** 版本序列号 **/
    private static final long serialVersionUID = 1L;

    /** 表名 **/
    public static final String TABLE = "usr_personal_address";

    /** 主键 **/
    private String id;

    /** 用户ID **/
    private String userId;

    /** 排序值(0为默认地址) **/
    private Integer sortIndex;

    /** 数据状态:0为正常|其他为删除 **/
    private DataState dataState;

    /** 获取主键 **/
    public String getId() {
        return id;
    }

    /** 设置主键 **/
    public void setId(String id) {
        this.id = id;
    }

    /** 获取用户ID **/
    public String getUserId() {
        return userId;
    }

    /** 设置用户ID **/
    public void setUserId(String userId) {
        this.userId = userId;
    }

    /** 获取排序值(0为默认地址) **/
    public Integer getSortIndex() {
        return sortIndex;
    }

    /** 设置排序值(0为默认地址) **/
    public void setSortIndex(Integer sortIndex) {
        this.sortIndex = sortIndex;
    }

    /** 获取数据状态:0为正常|其他为删除 **/
    public DataState getDataState() {
        return dataState;
    }

    /** 设置数据状态:0为正常|其他为删除 **/
    public void setDataState(DataState dataState) {
        this.dataState = dataState;
    }

    /**
     * 将当前对象转换为子类对象
     *
     * @param clazz 目标类型
     * @return 目标对象
     */
    public <T extends PersonalAddressBase> T to(Class<T> clazz) {
        T instance = super.to(clazz);

        if (instance instanceof PersonalAddressBean) {
            PersonalAddressBean real = (PersonalAddressBean) instance;
            real.setId(this.getId()); // 主键
            real.setUserId(this.getUserId()); // 用户ID
            real.setSortIndex(this.getSortIndex()); // 排序值(0为默认地址)
            real.setDataState(this.getDataState()); // 数据状态:0为正常|其他为删除
        }

        return instance;
    }

}
